package com.hnchances.weatherTest;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class QWeatherService {
    private static final String API_KEY = "93f206d1fa28457fa98c907083adc775";
    private static final OkHttpClient client = new OkHttpClient();
    private static final String BASE_URL = "https://ja65nn3293.re.qweatherapi.com";

    public static String getWeather(String locationId) throws Exception {
        String url = BASE_URL +"/v7/weather/now?location="
                + locationId + "&key=" + API_KEY;

        Request request = new Request.Builder()
                .url(url)
                .build();

        try (Response response = client.newCall(request).execute()) {
            return response.body().string();
        }
    }
}
